#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

int MaxProfit(int* a, int n,int pre)
{
	if (pre == n) return 0;
	int max1,max2=0,temp;
	max1 = a[pre + 1] - a[pre];
	for(int i = pre+1; i < n; i++)
	{
		temp = a[i] - a[pre];
		if (temp > max1) max1 = temp;
	}
	max2 = MaxProfit(a, n, pre+1);
	if (max1 > max2) return max1;
	else return max2;
}
int main()
{
	int n;
	int max;
	int* a;
	scanf("%d", &n);
	a = (int*)malloc(sizeof(int) * n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	max = MaxProfit(a, n, 0);
	printf("%d\n", max);
	return 0;
}